| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296 |
- package com.chinaitop.depot.agent.bgz.controller;
- import java.io.UnsupportedEncodingException;
- import java.lang.reflect.Parameter;
- import java.math.BigDecimal;
- import java.net.URLEncoder;
- import java.util.Date;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- import javax.annotation.Resource;
- import com.alibaba.fastjson.JSON;
- import com.chinaitop.utils.HTTPUtils;
- import org.springframework.http.MediaType;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestMethod;
- import org.springframework.web.bind.annotation.RestController;
- import com.chinaitop.depot.agent.basic.model.BusinessAgentDepot;
- import com.chinaitop.depot.agent.bgz.model.BusinessAgentBgmxz;
- import com.chinaitop.depot.agent.bgz.service.BusinessAgentBgmxzService;
- import com.chinaitop.utils.ParameterUtil;
- import com.fasterxml.jackson.databind.ObjectMapper;
- import com.github.pagehelper.PageHelper;
- import com.github.pagehelper.PageInfo;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiImplicitParam;
- import io.swagger.annotations.ApiImplicitParams;
- import io.swagger.annotations.ApiOperation;
- import net.sf.json.JSONArray;
- import net.sf.json.JSONObject;
- @RestController
- @RequestMapping(value = "/agent_bgmxz")
- @Api(description = "代储库保管明细账控制类")
- public class BusinessAgentBgmxzController {
- @Resource
- private BusinessAgentBgmxzService bgmxzService;
- @RequestMapping(value = "/getList", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.GET)
- @ApiOperation(value="代储库保管明细账信息列表", notes = "代储库保管明细账信息列表")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "pageNum", value = "页码", paramType = "query"),
- @ApiImplicitParam(name = "pageSize", value = "每页条数", paramType = "query"),
- @ApiImplicitParam(name = "agentId", value = "代储点ID", paramType = "query"),
- @ApiImplicitParam(name = "szlkOrgId", value = "代储库ID", paramType = "query"),
- @ApiImplicitParam(name = "houseId", value = "代储库仓房ID", paramType = "query"),
- @ApiImplicitParam(name = "wareId", value = "代储库货位id", paramType = "query"),
- @ApiImplicitParam(name = "fssj", value = "业务发生时间", paramType = "query"),
- @ApiImplicitParam(name = "orgId", value = "单位ID", paramType = "query")
- })
- public PageInfo<BusinessAgentBgmxz> list(Integer pageNum, Integer pageSize, Integer agentId, Integer szlkOrgId,
- Integer houseId, Integer wareId, String fssj, Integer orgId) {
- /* 代储点ID */
- Map<String, Object> param_map = new HashMap<String, Object>();
- if(ParameterUtil.isnotnull(agentId)){
- param_map.put("agentId", agentId);
- }
- /* 代储库ID */
- if(ParameterUtil.isnotnull(szlkOrgId)){
- param_map.put("szlkOrgId", szlkOrgId);
- }
- /* 仓房ID */
- if(ParameterUtil.isnotnull(houseId)){
- param_map.put("houseId", houseId);
- }
- /* 货位ID */
- if(ParameterUtil.isnotnull(wareId)){
- param_map.put("wareId", wareId);
- }
- /* 业务发生时间 */
- if(ParameterUtil.isnotnull(fssj)){
- Date startTime = ParameterUtil.string2datetime(fssj+" 00:00:00");
- Date endTime = ParameterUtil.string2datetime(fssj+" 23:59:59");
- param_map.put("startTime", startTime);
- param_map.put("endTime", endTime);
- }
- if (ParameterUtil.isnotnull(orgId)) {
- param_map.put("orgId", orgId);
- }
- /* 排序 */
- param_map.put("orderByClause", "a.fssj desc");
- /* 分页 */
- if(ParameterUtil.isnotnull(pageNum) && ParameterUtil.isnotnull(pageSize)){
- PageHelper.startPage(pageNum, pageSize);
- }
- List<BusinessAgentBgmxz> list = bgmxzService.findByConditions(param_map);
- PageInfo<BusinessAgentBgmxz> pageInfo = new PageInfo<BusinessAgentBgmxz>(list);
-
- return pageInfo;
- }
- @RequestMapping(value = "/findByMxbgz", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.GET)
- @ApiOperation(value="查看代储库保管明细账信息", notes = "查看代储库保管明细账信息")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "id", value = "数据ID", paramType = "query")
- })
- public BusinessAgentBgmxz findByMxbgz(Integer id) {
- BusinessAgentBgmxz bgmxz = null;
- if (null != id) {
- bgmxz = bgmxzService.findByParmaryKey(id);
- } else {
- bgmxz = new BusinessAgentBgmxz();
- }
- return bgmxz;
- }
- @RequestMapping(value = "/edit", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.POST)
- @ApiOperation(value="新增或修改代储库保管明细账信息", notes = "新增或修改代储库保管明细账信息")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "bgmxzJson", value = "数据对象", paramType = "form")
- })
- public Map<String, Object> edit(String bgmxzJson) {
- Map<String, Object> modelMap = new HashMap<String, Object>();
- // JSON字符串转对象
- ObjectMapper mapper = new ObjectMapper();
- try {
- BusinessAgentBgmxz bgmxz = (BusinessAgentBgmxz) mapper.readValue(bgmxzJson, BusinessAgentBgmxz.class);
- if (bgmxz.getId() != null) {
- bgmxzService.update(bgmxz);
- } else {
- bgmxzService.insert(bgmxz);
- }
- modelMap.put("status", "success");
- modelMap.put("msg", "操作成功!");
- } catch (Exception e) {
- e.printStackTrace();
- modelMap.put("status", "error");
- modelMap.put("msg", "操作失败!");
- }
- return modelMap;
- }
- @RequestMapping(value = "/remove", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.POST)
- @ApiOperation(value="新增或修改代储库保管明细账信息", notes = "新增或修改代储库保管明细账信息")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "id", value = "数据ID", paramType = "form")
- })
- public Map<String, Object> remove(Integer id) {
- Map<String, Object> modelMap = new HashMap<String, Object>();
- try {
- if (null != id) {
- bgmxzService.remove(id);
- modelMap.put("status", "success");
- modelMap.put("msg", "操作成功!");
- }
- } catch (Exception e) {
- e.printStackTrace();
- modelMap.put("status", "error");
- modelMap.put("msg", "操作失败!");
- }
- return modelMap;
- }
-
- @RequestMapping(value="/getFcbgzList", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.GET)
- @ApiOperation(value="分仓保管列表,按天统计", notes = "分仓保管列表,按天统计,支持分页")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "pageNum", value = "页码", paramType = "query"),
- @ApiImplicitParam(name = "pageSize", value = "每页条数", paramType = "query"),
- @ApiImplicitParam(name="bgmxzJson", value="数据对象", paramType="query")
- })
- public PageInfo<Map<String, Object>> getFcbgzList(Integer pageNum, Integer pageSize, String bgmxzJson) {
- Map<String, Object> paramMap = new HashMap<String, Object>();
- ObjectMapper mapper = new ObjectMapper();
- BusinessAgentBgmxz bgmxz = null;
- try {
- bgmxz = (BusinessAgentBgmxz) mapper.readValue(bgmxzJson, BusinessAgentBgmxz.class);
- } catch (Exception e) {
- e.printStackTrace();
- }
- if(ParameterUtil.isnotnull(bgmxz.getOrgId())){
- paramMap.put("orgId", bgmxz.getOrgId());
- }
- if(ParameterUtil.isnotnull(bgmxz.getAgentId())){
- paramMap.put("agentId", bgmxz.getAgentId());
- }
- if(ParameterUtil.isnotnull(bgmxz.getSzlkOrgId())){
- paramMap.put("szlkOrgId", bgmxz.getSzlkOrgId());
- }
- if(ParameterUtil.isnotnull(bgmxz.getHouseId())){
- paramMap.put("houseId", bgmxz.getHouseId());
- }
- if(ParameterUtil.isnotnull(bgmxz.getWareId())){
- paramMap.put("wareId", bgmxz.getWareId());
- }
- if(ParameterUtil.isnotnull(bgmxz.getLspz())){
- paramMap.put("lspz", bgmxz.getLspz());
- }
- if(ParameterUtil.isnotnull(bgmxz.getLsxz())){
- paramMap.put("lsxz", bgmxz.getLsxz());
- }
- if(ParameterUtil.isnotnull(bgmxz.getFssj())){
- paramMap.put("fssj", bgmxz.getFssj());
- }
- /* 分页 */
- if(ParameterUtil.isnotnull(pageNum) && ParameterUtil.isnotnull(pageSize)){
- PageHelper.startPage(pageNum, pageSize);
- }
- List<Map<String, Object>> list = bgmxzService.selectFcbgzList(paramMap);
-
- PageInfo<Map<String, Object>> pageInfo = new PageInfo<Map<String, Object>>(list);
- return pageInfo;
- }
- @RequestMapping(value="/selectAgentHouseWareList", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.GET)
- @ApiOperation(value="查询代储库正常使用的货位数据信息", notes = "查询代储库正常使用的货位数据信息")
- @ApiImplicitParams({
- @ApiImplicitParam(name="orgId", value="当前单位ID", paramType="query"),
- @ApiImplicitParam(name="stateType", value="路径状态", paramType="query")
- })
- public String selectAgentHouseWareList(Integer orgId,String stateType) throws Exception {
- Map<String, Object> paramMap = new HashMap<String, Object>();
- paramMap.put("orgId", orgId);
- List<Map<String, Object>> list = bgmxzService.selectAgentHouseWareList(paramMap);
- String str = JSON.toJSONString(list);
- String url = "";
- if(ParameterUtil.isequal(stateType,"kcsw")){
- url = "http://localhost:9026/agile/kcsw/queryKcswData";//库存实物
- }else if(ParameterUtil.isequal(stateType,"fcbgz")){
- url = "http://localhost:9026/agile/fcbgzController/queryFcbgzData";//分仓保管账
- }
- Map<String, Object> dataMap = new HashMap<String, Object>();
- dataMap.put("datas",str);
- String strResult = HTTPUtils.doPost(url,dataMap);
- return strResult;
- }
-
- @RequestMapping(value="/addCrkFcbgzData", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.POST)
- @ApiOperation(value="把出入库拿来的分仓保管账数据插入到代储库业务的分仓保管账表 中", notes = "把出入库拿来的分仓保管账数据插入到代储库业务的分仓保管账表 中")
- @ApiImplicitParams({
- @ApiImplicitParam(name="fcbgzData", value="出入库分仓保管账数据", paramType="form"),
- @ApiImplicitParam(name="orgId", value="当前单位ID", paramType="form"),
- @ApiImplicitParam(name="realName", value="当前操作人", paramType="form")
- })
- public Map<String, Object> addCrkFcbgzData(String fcbgzData, Integer orgId, String realName) {
- Map<String, Object> map = new HashMap<String, Object>();
- try {
- JSONArray json = JSONArray.fromObject(fcbgzData);
- if (json.size() > 0) {
- BusinessAgentBgmxz bgmxz = null;
- for (int i = 0; i < json.size(); i++) {
- bgmxz = new BusinessAgentBgmxz();
- JSONObject job = json.getJSONObject(i);
- bgmxz.setOrgId(orgId);
- Integer dckId = Integer.parseInt(job.get("unitid")+"");
- BusinessAgentDepot businessAgentDepot = bgmxzService.selectAgentDepotObj(orgId, dckId);
- bgmxz.setAgentId(Integer.parseInt(businessAgentDepot.getAgentId()));
- bgmxz.setSzlkOrgId(businessAgentDepot.getId());
- bgmxz.setHouseId(Integer.parseInt(job.get("ch")+""));
- bgmxz.setWareId(Integer.parseInt(job.get("hwh")+""));
- if(ParameterUtil.isnotnull(job.get("mxpz")))bgmxz.setLspz(Integer.parseInt(job.get("mxpz")+""));
- bgmxz.setLsxz(Integer.parseInt(job.get("hwxz")+""));
- bgmxz.setLsdj(Integer.parseInt(job.get("dj")+""));
- Date fssj = ParameterUtil.string2datetime(job.get("olddataid") + "");
- bgmxz.setFssj(fssj);
- BigDecimal number = new BigDecimal(job.get("srsl")+"");
- bgmxz.setSrsl(number);
- number = new BigDecimal(job.get("zcsl")+"");
- bgmxz.setZcsl(number);
- number = new BigDecimal(job.get("kcsl")+"");
- bgmxz.setKcsl(number);
- bgmxz.setIsJz(1);
- bgmxz.setSjly(1);
- bgmxz.setCreatePerson(realName);
- bgmxz.setCreateDate(fssj);
- //插入代储点的保管明细账表
- bgmxzService.insert(bgmxz);
- }
- //修改代储点货位表的保管明细账最后同步时间
- bgmxzService.updateAgentDepot(orgId);
- }
- map.put("status", "200");
- map.put("msg", "操作成功!");
- } catch (NumberFormatException e) {
- map.put("msg", "操作失败!");
- e.printStackTrace();
- }
- return map;
- }
- }
|