Browse Source

将出库查询修改为全部查询,不按主表展示

lwx_dev
erdanergou 2 years ago
parent
commit
c349bff627
  1. 109
      src/main/java/com/dreamchaser/depository_manage/controller/DepositoryRecordController.java
  2. 20
      src/main/java/com/dreamchaser/depository_manage/depository_mapper/DepositoryRecordMapper.xml
  3. 12
      src/main/java/com/dreamchaser/depository_manage/entity/ApplicationOutRecord.java
  4. 158
      src/main/java/com/dreamchaser/depository_manage/service/impl/DepositoryRecordServiceImpl.java
  5. 7
      src/main/resources/templates/pages/depository/table-out.html

109
src/main/java/com/dreamchaser/depository_manage/controller/DepositoryRecordController.java

@ -1068,115 +1068,6 @@ public class DepositoryRecordController {
list = depositoryRecordService.findApplicationOutRecordPByUser(userByPort, map, userKey, token); list = depositoryRecordService.findApplicationOutRecordPByUser(userByPort, map, userKey, token);
countBy = depositoryRecordService.findApplicationOutRecordPCountByUser(userByPort, map); countBy = depositoryRecordService.findApplicationOutRecordPCountByUser(userByPort, map);
} }
Map<Long, UserByPort> userByPortMap = new HashMap<>();
for (ApplicationOutRecordP outRecordP : list) {
// 根据主订单获取所有子订单
List<ApplicationOutRecordMinP> applicationOutMinByParentId = depositoryRecordService.findApplicationOutMinByParentId(outRecordP.getId());
StringBuilder mname = new StringBuilder();
StringBuilder mcode = new StringBuilder();
StringBuilder mversion = new StringBuilder();
StringBuilder depositoryName = new StringBuilder();
double sumQuantity = 0;
double sumPrice = 0.0;
List<Long> depositoryIdList = new ArrayList<>();
List<String> mnameForMobiles = new ArrayList<>();
for (ApplicationOutRecordMinP applicationOutRecordMin : applicationOutMinByParentId) {
// 获取子订单信息
// 获取出库物料信息
Inventory inventory = materialService.findInventoryById(applicationOutRecordMin.getMid());
String brand = inventory.getBrand();
String version = inventory.getVersion();
if (brand == null) {
inventory.setBrand("");
brand = "";
}
if (version == null) {
inventory.setVersion("");
version = "";
}
// 获取出库物料仓库Id
Long depositoryId = applicationOutRecordMin.getDepositoryId();
if (!depositoryIdList.contains(depositoryId)) {
depositoryIdList.add(depositoryId);
}
String inventoryMname = inventory.getMname();
mname.append(inventoryMname).append(",");
mcode.append(inventory.getCode()).append(",");
String mversionItem = brand + " " + version;
mversion.append(mversionItem).append(",");
mnameForMobiles.add(inventoryMname + ":" + mversionItem);
sumQuantity += applicationOutRecordMin.getQuantity();
String unit = applicationOutRecordMin.getUnit();
if ("-1".equals(unit)) {
double amounts = ObjectFormatUtil.multiply(inventory.getPrice(), applicationOutRecordMin.getQuantity());
sumPrice = ObjectFormatUtil.sum(sumPrice, amounts);
} else {
// 获取当前对应的拆单记录
Map<String, Object> paramForSplitInfo = new HashMap<>();
paramForSplitInfo.put("mid", inventory.getMid());
paramForSplitInfo.put("newUnit", unit);
SplitInfo splitInfo = splitUnitService.findSplitInfoByMidAndUnit(paramForSplitInfo);
// 获取当前拆单记录与基础单位进制
int splitInfoScaleQuantity = splitUnitService.findSplitInfoScaleQuantity(splitInfo, -1L);
BigDecimal bg = new BigDecimal(inventory.getPrice() / splitInfoScaleQuantity * applicationOutRecordMin.getQuantity());
double newprice = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
sumPrice = ObjectFormatUtil.sum(sumPrice, newprice);
}
}
outRecordP.setMcode(mcode.toString());
outRecordP.setMname(mname.toString());
outRecordP.setMversion(mversion.toString());
List<Depository> depositoryList = depositoryService.findDepositoryByIds(depositoryIdList);
for (Depository depository : depositoryList
) {
depositoryName.append(depository.getDname()).append(",");
}
// 部门负责人
String departmentHead = outRecordP.getDepartmenthead();
String[] split = departmentHead.split(",");
if ("".equals(departmentHead) || departmentHead.isEmpty()) {
// 如果当前没有部门负责人
split = new String[0];
}
String useAdminorgName = "";
for (String value : split) {
if ("".equals(value)) {
continue;
}
UserByPort departmenthead = null;
Long departmentheadId = ObjectFormatUtil.toLong(value);
if (userByPortMap.containsKey(departmentheadId)) {
departmenthead = userByPortMap.get(departmentheadId);
} else {
departmenthead = userService.findUserById(departmentheadId);
userByPortMap.put(departmentheadId, departmenthead);
}
// 获取用户的用工关系
int emptype = departmenthead.getEmptype();
if (emptype > 10) {
continue;
}
if ("".equals(useAdminorgName)) {
useAdminorgName = departmenthead.getMaindeparmentname();
} else {
break;
}
}
// 用于判断是否全审批完成
if ("3".equals(outRecordP.getDepartmentheadPass()) || "3".equals(outRecordP.getDepositoryManagerPass()) || (outRecordP.getBalancePosterPass() != null && "3".equals(outRecordP.getBalancePosterPass()))) {
outRecordP.setAllApproval(false);
} else {
outRecordP.setAllApproval(true);
}
outRecordP.setUseAdminorgName(useAdminorgName);
outRecordP.setDepositoryName(depositoryName.toString());
outRecordP.setQuantity(sumQuantity);
outRecordP.setPrice(sumPrice);
outRecordP.setMnameStringList(mnameForMobiles);
}
return new RestResponse(list, countBy, 200); return new RestResponse(list, countBy, 200);
} }

20
src/main/java/com/dreamchaser/depository_manage/depository_mapper/DepositoryRecordMapper.xml

@ -117,9 +117,11 @@
<result column="istransfer" property="istransfer" jdbcType="INTEGER"/> <result column="istransfer" property="istransfer" jdbcType="INTEGER"/>
<result column="mcode" property="mcode" jdbcType="VARCHAR"/> <result column="mcode" property="mcode" jdbcType="VARCHAR"/>
<result column="mversion" property="mversion" jdbcType="VARCHAR"/> <result column="mversion" property="mversion" jdbcType="VARCHAR"/>
<result column="munit" property="munit" jdbcType="VARCHAR"/>
<result column="placeId" property="placeId" jdbcType="BIGINT"/> <result column="placeId" property="placeId" jdbcType="BIGINT"/>
<result column="pass" property="pass" jdbcType="INTEGER"/> <result column="pass" property="pass" jdbcType="INTEGER"/>
<result column="aormUnit" property="unit" jdbcType="VARCHAR"/> <result column="aormUnit" property="unit" jdbcType="VARCHAR"/>
<result column="mprice" property="mprice" jdbcType="INTEGER"/>
<result column="abstract" property="abstracts" jdbcType="VARCHAR"/> <result column="abstract" property="abstracts" jdbcType="VARCHAR"/>
<result column="cuname" property="constructionUnitName" jdbcType="VARCHAR"/> <result column="cuname" property="constructionUnitName" jdbcType="VARCHAR"/>
<result column="outType" property="outType" jdbcType="INTEGER"/> <result column="outType" property="outType" jdbcType="INTEGER"/>
@ -187,7 +189,7 @@
<sql id="ApplicationOutRecordInfo"> <sql id="ApplicationOutRecordInfo">
aorid,mid,mname,depositoryId,dname,applicantId,applicantTime,applyRemark,aorcode,aorpirce,aorquantity,departmenthead,departmentheadPass,departmentHeadTime,departmentheadMessage, aorid,mid,mname,depositoryId,dname,applicantId,applicantTime,applyRemark,aorcode,aorpirce,aorquantity,departmenthead,departmentheadPass,departmentHeadTime,departmentheadMessage,
depositoryManager,depositoryManagerPass,depositoryManagerTime,depositoryManagerMessage,aorstate,istransfer,mcode,placeId,pass,aormUnit,aorconstructionunitid,aoradminorgid,cuname, depositoryManager,depositoryManagerPass,depositoryManagerTime,depositoryManagerMessage,aorstate,istransfer,mcode,placeId,pass,aormUnit,aorconstructionunitid,aoradminorgid,cuname,
cuintroduce,cuaddress,outTime,abstract,outType,editUser,mbrand,mversion,flagForOpenDepository,createUid,flagForAgency,balancePoster,balancePosterTime,balancePosterPass,balancePosterMessage,outTypeName cuintroduce,cuaddress,outTime,abstract,outType,munit,mprice,editUser,mbrand,mversion,flagForOpenDepository,createUid,flagForAgency,balancePoster,balancePosterTime,balancePosterPass,balancePosterMessage,outTypeName
</sql> </sql>
<sql id="ApplicationOutRecordMinInfo"> <sql id="ApplicationOutRecordMinInfo">
@ -637,7 +639,9 @@
<if test="constructionunitid != null and constructionunitid != ''"> <if test="constructionunitid != null and constructionunitid != ''">
and constructionunitid = #{constructionunitid} and constructionunitid = #{constructionunitid}
</if> </if>
<if test="isGroup != null and isGroup != ''">
GROUP BY aorid GROUP BY aorid
</if>
<if test="groupByForState != null and groupByForState !=''"> <if test="groupByForState != null and groupByForState !=''">
ORDER BY pass DESC,depositoryManagerPass asc, applicantTime desc ORDER BY pass DESC,depositoryManagerPass asc, applicantTime desc
</if> </if>
@ -703,8 +707,9 @@
<if test="constructionunitid != null and constructionunitid != ''"> <if test="constructionunitid != null and constructionunitid != ''">
and constructionunitid = #{constructionunitid} and constructionunitid = #{constructionunitid}
</if> </if>
<if test="isGroup != null and isGroup != ''">
GROUP BY aorid GROUP BY aorid
</if>
<if test="groupByForState != null and groupByForState !=''"> <if test="groupByForState != null and groupByForState !=''">
ORDER BY pass DESC,depositoryManagerPass asc, applicantTime desc ORDER BY pass DESC,depositoryManagerPass asc, applicantTime desc
</if> </if>
@ -718,7 +723,12 @@
<select id="findApplicationOutRecordPCountByUser" resultType="int" parameterType="map"> <select id="findApplicationOutRecordPCountByUser" resultType="int" parameterType="map">
select select
<if test="isGroup == null or isGroup == ''">
count(*)
</if>
<if test="isGroup != null and isGroup != ''">
count(DISTINCT aorid) count(DISTINCT aorid)
</if>
from applicationOutRecordInfo from applicationOutRecordInfo
where 1 = 1 and mid is not null where 1 = 1 and mid is not null
<if test="depositoryIdList != null"> <if test="depositoryIdList != null">
@ -927,7 +937,13 @@
<!-- 根据条件查询出库记录数--> <!-- 根据条件查询出库记录数-->
<select id="findApplicationOutRecordPCountByCondition" parameterType="map" resultType="int"> <select id="findApplicationOutRecordPCountByCondition" parameterType="map" resultType="int">
select select
<if test="isGroup == null or isGroup == ''">
count(*)
</if>
<if test="isGroup != null and isGroup != ''">
count(DISTINCT aorid) count(DISTINCT aorid)
</if>
from applicationOutRecordInfo from applicationOutRecordInfo
where 1 = 1 and mid is not null where 1 = 1 and mid is not null
<if test="id != '' and id != null"> <if test="id != '' and id != null">

12
src/main/java/com/dreamchaser/depository_manage/entity/ApplicationOutRecord.java

@ -19,6 +19,13 @@ public class ApplicationOutRecord {
*/ */
private String mname; private String mname;
/**
* 物料单位
*/
private String munit;
/** /**
* 仓库id * 仓库id
*/ */
@ -65,6 +72,11 @@ public class ApplicationOutRecord {
*/ */
private Integer quantity; private Integer quantity;
/**
* 物料单价
*/
private Integer mprice;
/** /**
* 部门负责人编号 * 部门负责人编号
*/ */

158
src/main/java/com/dreamchaser/depository_manage/service/impl/DepositoryRecordServiceImpl.java

@ -4932,24 +4932,93 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
List<ApplicationOutRecord> list = depositoryRecordMapper.findApplicationOutRecordPByUser(map); List<ApplicationOutRecord> list = depositoryRecordMapper.findApplicationOutRecordPByUser(map);
List<ApplicationOutRecordP> result = new ArrayList<>(); List<ApplicationOutRecordP> result = new ArrayList<>();
Map<Long, UserByPort> userByPortMap = new HashMap<>(); Map<Long, UserByPort> userByPortMap = new HashMap<>();
for (ApplicationOutRecord record : list) { for (ApplicationOutRecord recordP : list) {
Long applicantId = record.getApplicantId(); if (recordP.getQuantity() == null || 0 == recordP.getQuantity()) {
continue;
}
String unit = recordP.getUnit();
// 当前单的总额
double amounts = 0.0;
// 当前物料单价
double mprice = ObjectFormatUtil.divide(recordP.getMprice(),100.0,2);
// 当前出库数
double quantity = ObjectFormatUtil.divide(recordP.getQuantity(),100.0,2);
if ("-1".equals(unit) || unit.equals("")) {
amounts = ObjectFormatUtil.multiply(mprice, quantity);
} else {
// // 获取当前对应的拆单记录
Map<String, Object> paramForSplitInfo = new HashMap<>();
paramForSplitInfo.put("mid", recordP.getMid());
paramForSplitInfo.put("newUnit", unit);
SplitInfo splitInfo = splitUnitMapper.findSplitInfoByMidAndUnit(paramForSplitInfo);
// // 获取当前拆单记录与基础单位进制
int splitInfoScaleQuantity = splitUnitService.findSplitInfoScaleQuantity(splitInfo, -1L);
BigDecimal bg = new BigDecimal(mprice / splitInfoScaleQuantity * quantity);
amounts = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
}
recordP.setPrice(amounts);
// 获取当前申请人id
Long applicantId = recordP.getApplicantId();
// 声明申请人信息
UserByPort userByPortById = null; UserByPort userByPortById = null;
if (userByPortMap.containsKey(applicantId)) { if (userByPortMap.containsKey(applicantId)) {
userByPortById = userByPortMap.get(applicantId); userByPortById = userByPortMap.get(applicantId);
} else { }
else {
userByPortById = userMapper.findUserById(applicantId); userByPortById = userMapper.findUserById(applicantId);
Administration departmentByUser = administrativeService.getDepartmentByUser(userByPortById); Administration departmentByUser = administrativeService.getDepartmentByUser(userByPortById);
userByPortById.setMaindeparmentname(departmentByUser.getName()); userByPortById.setMaindeparmentname(departmentByUser.getName());
userByPortMap.put(applicantId, userByPortById); userByPortMap.put(applicantId, userByPortById);
} }
String time = DateUtil.TimeStampToDateTime(ObjectFormatUtil.toLong(record.getApplicantTime()));
record.setApplicantName(userByPortById.getName());
record.setApplicantTime(time); // 部门负责人
record.setApplyRemark(record.getApplyRemark() == null ? "" : record.getApplyRemark()); String departmentHead = recordP.getDepartmenthead();
ApplicationOutRecordP recordP = new ApplicationOutRecordP(record); String[] split = departmentHead.split(",");
recordP.setAdminorgName(userByPortById.getMaindeparmentname()); if ("".equals(departmentHead) || departmentHead.isEmpty()) {
result.add(recordP); // 如果当前没有部门负责人
split = new String[0];
}
String useAdminorgName = "";
for (String value : split) {
if ("".equals(value)) {
continue;
}
UserByPort departmenthead = null;
Long departmentheadId = ObjectFormatUtil.toLong(value);
if (userByPortMap.containsKey(departmentheadId)) {
departmenthead = userByPortMap.get(departmentheadId);
} else {
departmenthead = userMapper.findUserById(departmentheadId);
Administration departmentByUser = administrativeService.getDepartmentByUser(departmenthead);
departmenthead.setMaindeparmentname(departmentByUser.getName());
userByPortMap.put(departmentheadId, departmenthead);
}
// 获取用户的用工关系
int emptype = departmenthead.getEmptype();
if (emptype > 10) {
continue;
}
if ("".equals(useAdminorgName)) {
useAdminorgName = departmenthead.getMaindeparmentname();
} else {
break;
}
}
String time = DateUtil.TimeStampToDateTime(ObjectFormatUtil.toLong(recordP.getApplicantTime()));
recordP.setApplicantName(userByPortById.getName());
recordP.setApplicantTime(time);
recordP.setApplyRemark(recordP.getApplyRemark() == null ? "" : recordP.getApplyRemark());
ApplicationOutRecordP aorp = new ApplicationOutRecordP(recordP);
aorp.setAdminorgName(userByPortById.getMaindeparmentname());
if ("3".equals(aorp.getDepartmentheadPass()) || "3".equals(aorp.getDepositoryManagerPass()) || (aorp.getBalancePosterPass() != null && "3".equals(aorp.getBalancePosterPass()))) {
aorp.setAllApproval(false);
} else {
aorp.setAllApproval(true);
}
aorp.setUseAdminorgName(useAdminorgName);
result.add(aorp);
} }
return result; return result;
} }
@ -5023,23 +5092,88 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
if (recordP.getQuantity() == null || 0 == recordP.getQuantity()) { if (recordP.getQuantity() == null || 0 == recordP.getQuantity()) {
continue; continue;
} }
String unit = recordP.getUnit();
// 当前单的总额
double amounts = 0.0;
// 当前物料单价
double mprice = ObjectFormatUtil.divide(recordP.getMprice(),100.0,2);
// 当前出库数
double quantity = ObjectFormatUtil.divide(recordP.getQuantity(),100.0,2);
if ("-1".equals(unit) || unit.equals("")) {
amounts = ObjectFormatUtil.multiply(mprice, quantity);
} else {
// // 获取当前对应的拆单记录
Map<String, Object> paramForSplitInfo = new HashMap<>();
paramForSplitInfo.put("mid", recordP.getMid());
paramForSplitInfo.put("newUnit", unit);
SplitInfo splitInfo = splitUnitMapper.findSplitInfoByMidAndUnit(paramForSplitInfo);
// // 获取当前拆单记录与基础单位进制
int splitInfoScaleQuantity = splitUnitService.findSplitInfoScaleQuantity(splitInfo, -1L);
BigDecimal bg = new BigDecimal(mprice / splitInfoScaleQuantity * quantity);
amounts = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
}
recordP.setPrice(amounts);
// 获取当前申请人id
Long applicantId = recordP.getApplicantId(); Long applicantId = recordP.getApplicantId();
// 声明申请人信息
UserByPort userByPortById = null; UserByPort userByPortById = null;
if (userByPortMap.containsKey(applicantId)) { if (userByPortMap.containsKey(applicantId)) {
userByPortById = userByPortMap.get(applicantId); userByPortById = userByPortMap.get(applicantId);
} else { }
else {
userByPortById = userMapper.findUserById(applicantId); userByPortById = userMapper.findUserById(applicantId);
Administration departmentByUser = administrativeService.getDepartmentByUser(userByPortById); Administration departmentByUser = administrativeService.getDepartmentByUser(userByPortById);
userByPortById.setMaindeparmentname(departmentByUser.getName()); userByPortById.setMaindeparmentname(departmentByUser.getName());
userByPortMap.put(applicantId, userByPortById); userByPortMap.put(applicantId, userByPortById);
} }
// 部门负责人
String departmentHead = recordP.getDepartmenthead();
String[] split = departmentHead.split(",");
if ("".equals(departmentHead) || departmentHead.isEmpty()) {
// 如果当前没有部门负责人
split = new String[0];
}
String useAdminorgName = "";
for (String value : split) {
if ("".equals(value)) {
continue;
}
UserByPort departmenthead = null;
Long departmentheadId = ObjectFormatUtil.toLong(value);
if (userByPortMap.containsKey(departmentheadId)) {
departmenthead = userByPortMap.get(departmentheadId);
} else {
departmenthead = userMapper.findUserById(departmentheadId);
Administration departmentByUser = administrativeService.getDepartmentByUser(departmenthead);
departmenthead.setMaindeparmentname(departmentByUser.getName());
userByPortMap.put(departmentheadId, departmenthead);
}
// 获取用户的用工关系
int emptype = departmenthead.getEmptype();
if (emptype > 10) {
continue;
}
if ("".equals(useAdminorgName)) {
useAdminorgName = departmenthead.getMaindeparmentname();
} else {
break;
}
}
String time = DateUtil.TimeStampToDateTime(ObjectFormatUtil.toLong(recordP.getApplicantTime())); String time = DateUtil.TimeStampToDateTime(ObjectFormatUtil.toLong(recordP.getApplicantTime()));
recordP.setApplicantName(userByPortById.getName()); recordP.setApplicantName(userByPortById.getName());
recordP.setApplicantTime(time); recordP.setApplicantTime(time);
recordP.setApplyRemark(recordP.getApplyRemark() == null ? "" : recordP.getApplyRemark()); recordP.setApplyRemark(recordP.getApplyRemark() == null ? "" : recordP.getApplyRemark());
ApplicationOutRecordP aorp = new ApplicationOutRecordP(recordP); ApplicationOutRecordP aorp = new ApplicationOutRecordP(recordP);
aorp.setAdminorgName(userByPortById.getMaindeparmentname()); aorp.setAdminorgName(userByPortById.getMaindeparmentname());
if ("3".equals(aorp.getDepartmentheadPass()) || "3".equals(aorp.getDepositoryManagerPass()) || (aorp.getBalancePosterPass() != null && "3".equals(aorp.getBalancePosterPass()))) {
aorp.setAllApproval(false);
} else {
aorp.setAllApproval(true);
}
aorp.setUseAdminorgName(useAdminorgName);
result.add(aorp); result.add(aorp);
} }
return result; return result;

7
src/main/resources/templates/pages/depository/table-out.html

@ -184,10 +184,9 @@
let cols = [ let cols = [
{type: "checkbox", width: 50}, {type: "checkbox", width: 50},
{field: "code", title: '申请编码', width: 150,}, {field: "code", title: '申请编码', width: 200,},
// {field: 'mname', width: 150, title: '物料名称'}, {field: 'mname', width: 150, title: '物料名称'},
{field: 'mname', width: 200, title: '物料名称', templet: '#mnameSelect'}, // {field: 'mname', width: 200, title: '物料名称', templet: '#mnameSelect'},
{field: 'mcode', width: 150, title: '存货编码'}, {field: 'mcode', width: 150, title: '存货编码'},
{field: 'quantity', width: 100, title: '数量', sort: true}, {field: 'quantity', width: 100, title: '数量', sort: true},
{field: 'depositoryName', width: 150, title: '仓库名称'}, {field: 'depositoryName', width: 150, title: '仓库名称'},

Loading…
Cancel
Save