| | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import zy.cloud.wms.common.web.BaseController; |
| | | import zy.cloud.wms.manager.entity.WrkSts; |
| | | import zy.cloud.wms.manager.service.WrkStsService; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Optional; |
| | | |
| | | /** |
| | |
| | | |
| | | @Autowired |
| | | private JdbcTemplate jdbcTemplate; |
| | | @Autowired |
| | | private WrkStsService wrkStsService; |
| | | |
| | | /** |
| | | * 当天数据:select * from tableName where datediff(day, 字段名,getdate())=0 |
| | |
| | | ); |
| | | } |
| | | |
| | | @RequestMapping(value = "/body/auth") |
| | | public R body() { |
| | | // 组托 |
| | | List<Map<String, Object>> combList = jdbcTemplate.queryForList("select top 10 * from man_comb where 1=1 order by create_time desc"); |
| | | for (int i=0;i<combList.size();i++) { |
| | | Object create_time = combList.get(i).get("create_time"); |
| | | combList.get(i).put("time", String.valueOf(create_time).substring(5, 16)); |
| | | combList.get(i).put("active", i<3?"active":""); |
| | | } |
| | | // 拣货单 |
| | | List<Map<String, Object>> pakoutList = jdbcTemplate.queryForList("select top 5 * from man_pakout where 1=1 order by create_time desc"); |
| | | for (int i=0;i<pakoutList.size();i++) { |
| | | pakoutList.get(i).put("no", i+1); |
| | | String wrk_sts = String.valueOf(pakoutList.get(i).get("wrk_sts")); |
| | | switch (wrk_sts) { |
| | | case "1": |
| | | pakoutList.get(i).put("style", "text-warning"); |
| | | break; |
| | | case "2": |
| | | pakoutList.get(i).put("style", "text-danger"); |
| | | break; |
| | | case "3": |
| | | pakoutList.get(i).put("style", "text-success"); |
| | | break; |
| | | default: |
| | | pakoutList.get(i).put("style", "text-info"); |
| | | break; |
| | | } |
| | | WrkSts wrkSts = wrkStsService.selectById(Integer.parseInt(wrk_sts)); |
| | | if (null != wrkSts) { |
| | | pakoutList.get(i).put("wrkStsName", wrkSts.getStsName()); |
| | | } |
| | | } |
| | | // 安全库存警告 |
| | | List<Map<String, Object>> safeQuaList = jdbcTemplate.queryForList("select \n" + |
| | | "top 10\n" + |
| | | "mp.node_id,\n" + |
| | | "mp.node_name,\n" + |
| | | "mp.matnr,\n" + |
| | | "mp.maktx,\n" + |
| | | "mp.safe_qua,\n" + |
| | | "mld.anfme,\n" + |
| | | "(mp.safe_qua - mld.anfme) as dValue\n" + |
| | | "from man_prior mp\n" + |
| | | "left join \n" + |
| | | "(select SUM(anfme) as anfme, node_id from man_loc_detl where 1=1 group by node_id) mld on mp.node_id = mld.node_id\n" + |
| | | "where 1=1 \n" + |
| | | "and mp.safe_qua > mld.anfme\n" + |
| | | "order by (mp.safe_qua - mld.anfme) desc"); |
| | | for (int i=0;i<safeQuaList.size();i++) { |
| | | safeQuaList.get(i).put("no", i+1); |
| | | if (Cools.isEmpty(safeQuaList.get(i).get("dValue"))){ |
| | | safeQuaList.get(i).put("dValue", safeQuaList.get(i).get("safe_qua")); |
| | | } |
| | | } |
| | | // 库存滞留 |
| | | List<Map<String, Object>> retentionList = jdbcTemplate.queryForList("select top 6 CONVERT(decimal, DATEDIFF(second, man_loc_detl.create_time, GETDATE()) / 86400.0, 9) AS stayDays, * from man_loc_detl order by create_time desc"); |
| | | for (int i=0;i<retentionList.size();i++) { |
| | | retentionList.get(i).put("no", i+1); |
| | | Object create_time = combList.get(i).get("create_time"); |
| | | retentionList.get(i).put("createTime", String.valueOf(create_time).substring(0, 11)); |
| | | } |
| | | |
| | | return R.ok().add(Cools |
| | | .add("combList", combList) // 组托最新动态 |
| | | .add("pakoutList", pakoutList) // 最新拣货单 |
| | | .add("safeQuaList", safeQuaList) // 安全库存警告 |
| | | .add("retentionList", retentionList) // 库存滞留数据 |
| | | ); |
| | | } |
| | | |
| | | } |