package zy.cloud.wms.manager.controller; import com.core.annotations.ManagerAuth; import com.core.common.Cools; import com.core.common.R; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jdbc.core.JdbcTemplate; 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; /** * Created by vincent on 2021/3/5 */ @RestController @RequestMapping("console") public class ConsoleController extends BaseController { @Autowired private JdbcTemplate jdbcTemplate; @Autowired private WrkStsService wrkStsService; /** * 当天数据:select * from tableName where datediff(day, 字段名,getdate())=0 * 本周数据:select * from tableName where datediff(week, 字段名,getdate())=0 * 本月:select * from tableName where datediff(month, 字段名,getdate())=0 * 本季度:内select * from tableName where datediff(quarter, 字段名,getdate())=0 * 本年:select * from tableName where datediff(year, 字段名,getdate())=0 */ @RequestMapping(value = "/header/auth") @ManagerAuth public R header() { Long hostId = getHostId(); Integer pakinQtyDay = jdbcTemplate.queryForObject("select ISNULL(sum(anfme), 0) from man_pakin where datediff(day, create_time, getdate())=0".concat(hostId==null?"":" and host_id="+hostId), Integer.class); Integer pakinQty = jdbcTemplate.queryForObject("select ISNULL(sum(anfme), 0) from man_pakin".concat(hostId==null?"":" where host_id="+hostId), Integer.class); Integer matQty = jdbcTemplate.queryForObject("select count(*) from man_mat".concat(hostId==null?"":" where host_id="+hostId), Integer.class); Integer nodeQty = jdbcTemplate.queryForObject("select count(*) from man_node where type = 3".concat(hostId==null?"":" and host_id="+hostId), Integer.class); Integer pakoutQty = jdbcTemplate.queryForObject("select count(*) from man_pakout".concat(hostId==null?"":" where host_id="+hostId), Integer.class); Integer pakoutQtyMonth = jdbcTemplate.queryForObject("select count(*) from man_pakout where datediff(month, create_time, getdate())=0".concat(hostId==null?"":" and host_id="+hostId), Integer.class); Integer usersQty = jdbcTemplate.queryForObject("select count(*) from sys_user".concat(hostId==null?"":" where host_id="+hostId), Integer.class); Integer deptQty = jdbcTemplate.queryForObject("select count(*) from sys_dept".concat(hostId==null?"":" where host_id="+hostId), Integer.class); Integer optQty = jdbcTemplate.queryForObject("select count(*) from sys_operate_log".concat(hostId==null?"":" where host_id="+hostId), Integer.class); return R.ok().add(Cools .add("pakinQtyDay", Optional.ofNullable(pakinQtyDay).orElse(0)) // 组托数量(当天) .add("pakinQty", Optional.ofNullable(pakinQty).orElse(0)) // 组托数量 .add("matQty", Optional.ofNullable(matQty).orElse(0)) // 物料数量 .add("nodeQty", Optional.ofNullable(nodeQty).orElse(0)) // 货位数量 .add("pakoutQty", Optional.ofNullable(pakoutQty).orElse(0)) // 总出库单数 .add("pakoutQtyMonth", Optional.ofNullable(pakoutQtyMonth).orElse(0)) // 出库单数(当月) .add("usersQty", Optional.ofNullable(usersQty).orElse(0)) // 用户数量 .add("deptQty", Optional.ofNullable(deptQty).orElse(0)) // 部门数量 .add("optQty", Optional.ofNullable(optQty).orElse(0)) // 操作次数 ); } @RequestMapping(value = "/body/auth") @ManagerAuth public R body() { Long hostId = getHostId(); // 组托 // List> combList = jdbcTemplate.queryForList("select top 10 * from man_comb where 1=1 order by create_time desc"); // for (int i=0;i> pakinList = jdbcTemplate.queryForList("select top 10 * from man_pakin where 1=1".concat(hostId==null?"":" and host_id="+hostId) + " order by create_time desc"); for (int i=0;i> pakoutList = jdbcTemplate.queryForList("select top 5 * from man_pakout where 1=1".concat(hostId==null?"":" and host_id="+hostId) + " order by create_time desc"); for (int i=0;i> safeQuaList = jdbcTemplate.queryForList("select\n" + "top 6\n" + "mp.node_id,\n" + "mp.node_name,\n" + "mp.matnr,\n" + "mp.maktx,\n" + "mp.safe_qua,\n" + "ISNULL(ls.amount, 0) as amount,\n" + "(mp.safe_qua - isnull(ls.amount, 0)) as dValue\n" + "from man_prior mp\n" + "left join\n" + "(\n" + " select\n" + " node_id,\n" + " matnr,\n" + " sum(anfme) as amount\n" + " from man_loc_detl\n" + " group by node_id, matnr\n" + ") as ls on ls.node_id = mp.node_id and ls.matnr = mp.matnr\n" + "where 1=1\n" + "and mp.safe_qua > ls.amount or ls.amount is null\n" .concat(hostId==null?"":" and mp.host_id="+hostId) + "order by (mp.safe_qua - isnull(ls.amount, 0)) desc"); for (int i=0;i> retentionList = jdbcTemplate.queryForList("select top 7 CONVERT(decimal, DATEDIFF(second, man_loc_detl.create_time, GETDATE()) / 86400.0, 9) AS stayDays, * from man_loc_detl".concat(hostId==null?"":" where host_id="+hostId) + " order by stayDays desc"); for (int i=0;i