设计管理:材料明细表料单阶段比较报告
This commit is contained in:
@@ -107,7 +107,7 @@ public class MaterialOrderController extends BaseController {
|
||||
modelMap.addAttribute("productList", productService.findAll());
|
||||
modelMap.addAttribute("type", orderQuery.getMaterialType());
|
||||
modelMap.addAttribute("pageType",pageType);
|
||||
// modelMap.addAttribute("adminId",admin.getId());
|
||||
modelMap.addAttribute("adminId",admin.getId());
|
||||
Page<MaterialOrder> page = (Page<MaterialOrder>) modelMap.get("page");
|
||||
Map<Long,String> map = new HashMap<>();
|
||||
for (MaterialOrder materialOrder : page.getContent()){
|
||||
@@ -433,14 +433,30 @@ public class MaterialOrderController extends BaseController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入明细表页面中 根据前缀和阶段找以往阶段的料单
|
||||
* 导入明细表页面中及阶段比较功能 根据前缀和阶段找以往阶段的料单
|
||||
*/
|
||||
@RequestMapping(value = "/findPrevStageListDialog")
|
||||
public String findPrevStageListDialog(ModelMap modelMap, Long adminId, String preTitle, Long stage) {
|
||||
public String findPrevStageListDialog(ModelMap modelMap, Long adminId, String preTitle, Long stage, Long materialOrderId) {
|
||||
modelMap.addAttribute("materialOrderId", materialOrderId);
|
||||
modelMap.addAttribute("materialOrderList", materialOrderService.findPrevStageList(adminId, preTitle, stage));
|
||||
return "materialOrder/dialog/findPrevStageListDialog";
|
||||
}
|
||||
|
||||
/**
|
||||
* 对以往阶段的料单进行阶段比较
|
||||
*/
|
||||
@RequestMapping(value = "/PrevStageComparisonExcel")
|
||||
@ResponseBody
|
||||
public RespData PrevStageComparisonExcel(Long materialOrderId) {
|
||||
MaterialOrder materialOrder = materialOrderService.find(materialOrderId);
|
||||
if(materialOrder.getStageNum()==1){
|
||||
return RespData.error("该料单是第一阶段,无法进行阶段比较");
|
||||
} else {
|
||||
materialOrderService.PrevStageComparisonExcel(materialOrderId);
|
||||
return RespData.success("料单比较成功");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 导入明细表
|
||||
|
||||
@@ -83,6 +83,8 @@ public class MaterialOrder extends OrderBase{
|
||||
// this.stage = stage;
|
||||
// }
|
||||
|
||||
private Integer stage;
|
||||
|
||||
private String stageName;
|
||||
|
||||
private String stageCode;
|
||||
@@ -196,6 +198,14 @@ public class MaterialOrder extends OrderBase{
|
||||
this.bidStatus = bidStatus;
|
||||
}
|
||||
|
||||
public Integer getStage() {
|
||||
return stage;
|
||||
}
|
||||
|
||||
public void setStage(Integer stage) {
|
||||
this.stage = stage;
|
||||
}
|
||||
|
||||
public String getStageName() {
|
||||
return stageName;
|
||||
}
|
||||
|
||||
@@ -682,6 +682,7 @@ public class MaterialOrderService extends BaseOrderService<MaterialOrder, Long>
|
||||
}
|
||||
}
|
||||
}
|
||||
materialOrder.setStage(stage.getId().intValue());
|
||||
materialOrder.setStageCode(stage.getCode());
|
||||
materialOrder.setStageName(stage.getName());
|
||||
materialOrder.setStageNum(stage.getStageNum());
|
||||
@@ -1037,23 +1038,24 @@ public class MaterialOrderService extends BaseOrderService<MaterialOrder, Long>
|
||||
BigDecimal useCount = countMap.get(str);
|
||||
if (useCount!=null){
|
||||
count = needCount.subtract(useCount);
|
||||
countMap.remove(str);
|
||||
} else {
|
||||
count = needCount;
|
||||
}
|
||||
// count = needCount.subtract(useCount);
|
||||
//后续阶段数量意外减少
|
||||
if (count.compareTo(BigDecimal.ZERO)<0){
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
map.put("ind",item.getInd());
|
||||
map.put("name",item.getName());
|
||||
map.put("unit",item.getUnitAccount());
|
||||
map.put("site",item.getSiteAccount());
|
||||
map.put("line",item.getLineAccount());
|
||||
map.put("code",item.getProductCode());
|
||||
map.put("longDescription",item.getLongDescription());
|
||||
map.put("needCount",needCount);
|
||||
map.put("preCount",useCount);
|
||||
map.put("errorMessage","阶段提升后采购数量减少");
|
||||
specialList.add(map);
|
||||
// Map<String,Object> map = new HashMap<>();
|
||||
// map.put("ind",item.getInd());
|
||||
// map.put("name",item.getName());
|
||||
// map.put("unit",item.getUnitAccount());
|
||||
// map.put("site",item.getSiteAccount());
|
||||
// map.put("line",item.getLineAccount());
|
||||
// map.put("code",item.getProductCode());
|
||||
// map.put("longDescription",item.getLongDescription());
|
||||
// map.put("needCount",needCount);
|
||||
// map.put("preCount",useCount);
|
||||
// map.put("errorMessage","当前阶段较以往阶段采购数量减少");
|
||||
// specialList.add(map);
|
||||
count = BigDecimal.ZERO;
|
||||
}
|
||||
}
|
||||
@@ -1135,22 +1137,8 @@ public class MaterialOrderService extends BaseOrderService<MaterialOrder, Long>
|
||||
throw new ImportExcelException(failNum+"条导入失败", "3", map);
|
||||
}
|
||||
}
|
||||
if (!firstStage && countMap!=null && !countMap.isEmpty()){
|
||||
for (Map.Entry<String, BigDecimal> entry : countMap.entrySet()) {
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
map.put("ind","");
|
||||
map.put("name",entry.getKey().split("_")[0]);
|
||||
map.put("unit",entry.getKey().split("_")[15]);
|
||||
map.put("site",entry.getKey().split("_")[14]);
|
||||
map.put("line",entry.getKey().split("_")[12]);
|
||||
map.put("code",entry.getKey().split("_")[16]);
|
||||
map.put("longDescription",entry.getKey().split("_")[5]);
|
||||
map.put("needCount","无");
|
||||
map.put("preCount",entry.getValue());
|
||||
map.put("errorMessage","上阶段有,现阶段没有");
|
||||
specialList.add(map);
|
||||
System.out.println("Key = " + entry.getKey() + ", Value = " + entry.getValue());
|
||||
}
|
||||
if (!firstStage){
|
||||
PrevStageComparisonExcel(materialOrder.getId());
|
||||
}
|
||||
return specialList.size();
|
||||
}
|
||||
@@ -1187,13 +1175,102 @@ public class MaterialOrderService extends BaseOrderService<MaterialOrder, Long>
|
||||
lm.put("needCount", item.get("needCount"));
|
||||
lm.put("preCount", item.get("preCount"));
|
||||
lm.put("errorMessage", item.get("errorMessage"));
|
||||
|
||||
listMap.add(lm);
|
||||
}
|
||||
value.put("maplist", listMap);
|
||||
ExcelUtils.export(response, value, params, "料单数量问题.xlsx");
|
||||
ExcelUtils.export(response, value, params, "料单阶段比较报告.xlsx");
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void PrevStageComparisonExcel(Long materialOrderId){
|
||||
specialList = new ArrayList<>();
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
MaterialOrder materialOrder = find(materialOrderId);
|
||||
//获取以前阶段
|
||||
Map<String,BigDecimal> prevMap = new HashMap<>();
|
||||
Map<String,String> LongMap = new HashMap<>();
|
||||
List<MaterialOrder> prevMaterialOrderList = findByStageNum(materialOrder.getPreTitle(), materialOrder.getStageNum(), materialOrder.getProgressId());
|
||||
for (MaterialOrder prevMaterialOrder : prevMaterialOrderList) {
|
||||
List<MaterialOrderItem> prevItemList = materialOrderItemService.findByVersionNum(prevMaterialOrder.getVersionNum(), prevMaterialOrder.getId());
|
||||
for (MaterialOrderItem prevItem : prevItemList){
|
||||
String str = prevItem.getName()+"_"+prevItem.getUnitAccount()+"_"+prevItem.getSiteAccount()
|
||||
+"_"+prevItem.getLineAccount()+"_"+prevItem.getProductCode();
|
||||
if (!prevMap.containsKey(str)){
|
||||
prevMap.put(str,prevItem.getCount());
|
||||
}else {
|
||||
BigDecimal prevCount = prevMap.get(str).add(prevItem.getCount());
|
||||
prevMap.put(str,prevCount);
|
||||
}
|
||||
LongMap.put(str,prevItem.getLongDescription());
|
||||
}
|
||||
}
|
||||
//获取当前阶段
|
||||
List<MaterialOrderItem> itemList = materialOrderItemService.findByVersionNum(materialOrder.getVersionNum(), materialOrder.getId());
|
||||
for (MaterialOrderItem item : itemList){
|
||||
String str = item.getName()+"_"+item.getUnitAccount()+"_"+item.getSiteAccount()
|
||||
+"_"+item.getLineAccount()+"_"+item.getProductCode();
|
||||
if (prevMap.containsKey(str)){
|
||||
BigDecimal prevCount = prevMap.get(str);
|
||||
if (prevCount.compareTo(item.getNeedCount()) > 0){
|
||||
map = new HashMap<>();
|
||||
map.put("ind",item.getInd());
|
||||
map.put("name",item.getName());
|
||||
map.put("unit",item.getUnitAccount());
|
||||
map.put("site",item.getSiteAccount());
|
||||
map.put("line",item.getLineAccount());
|
||||
map.put("code",item.getProductCode());
|
||||
map.put("longDescription",item.getLongDescription());
|
||||
map.put("needCount",item.getNeedCount());
|
||||
map.put("preCount",prevCount);
|
||||
map.put("errorMessage","当前阶段较以往阶段采购数量减少");
|
||||
specialList.add(map);
|
||||
} else if (prevCount.compareTo(item.getNeedCount()) < 0) {
|
||||
map = new HashMap<>();
|
||||
map.put("ind",item.getInd());
|
||||
map.put("name",item.getName());
|
||||
map.put("unit",item.getUnitAccount());
|
||||
map.put("site",item.getSiteAccount());
|
||||
map.put("line",item.getLineAccount());
|
||||
map.put("code",item.getProductCode());
|
||||
map.put("longDescription",item.getLongDescription());
|
||||
map.put("needCount",item.getNeedCount());
|
||||
map.put("preCount",prevCount);
|
||||
map.put("errorMessage","当前阶段较以往阶段采购数量增加");
|
||||
specialList.add(map);
|
||||
}
|
||||
prevMap.remove(str);
|
||||
} else {
|
||||
map = new HashMap<>();
|
||||
map.put("ind",item.getInd());
|
||||
map.put("name",item.getName());
|
||||
map.put("unit",item.getUnitAccount());
|
||||
map.put("site",item.getSiteAccount());
|
||||
map.put("line",item.getLineAccount());
|
||||
map.put("code",item.getProductCode());
|
||||
map.put("longDescription",item.getLongDescription());
|
||||
map.put("needCount",item.getNeedCount());
|
||||
map.put("preCount",' ');
|
||||
map.put("errorMessage","当前阶段料单新增采购");
|
||||
specialList.add(map);
|
||||
}
|
||||
}
|
||||
for (Map.Entry<String,BigDecimal> entry : prevMap.entrySet()) {
|
||||
map = new HashMap<>();
|
||||
map.put("ind",' ');
|
||||
map.put("name",entry.getKey().split("_")[0]);
|
||||
map.put("unit",entry.getKey().split("_")[1]);
|
||||
map.put("site",entry.getKey().split("_")[2]);
|
||||
map.put("line",entry.getKey().split("_")[3]);
|
||||
map.put("code",entry.getKey().split("_")[4]);
|
||||
map.put("longDescription",LongMap.get(entry.getKey()));
|
||||
map.put("needCount",' ');
|
||||
map.put("preCount",entry.getValue());
|
||||
map.put("errorMessage","以往阶段已采购,当前阶段没有采购");
|
||||
specialList.add(map);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// @Transactional(propagation = Propagation.NESTED)
|
||||
//老版
|
||||
@Transactional
|
||||
|
||||
Binary file not shown.
@@ -177,6 +177,8 @@
|
||||
</th:block>
|
||||
<!-- <a data-permission="materialOrder:list"-->
|
||||
<!-- th:href="|javascript:Nav.go('materialOrder/view.html?id=${materialOrder.id}');|"> 查看</a>-->
|
||||
<a data-permission="materialOrder:list"
|
||||
th:onclick="|findPrevStageList('${adminId}','${materialOrder.preTitle}','${materialOrder.stage.longValue()}','${materialOrder.id}')|"> 阶段比较</a>
|
||||
</shiro:hasPermission>
|
||||
<th:block th:if="${pageType == 'design'}">
|
||||
<shiro:hasPermission name="materialOrder:edit">
|
||||
@@ -453,6 +455,14 @@
|
||||
$form.find('[name="ids"]').val(ids);
|
||||
$form.submit();
|
||||
}
|
||||
|
||||
function findPrevStageList(adminId,preTitle,stage,materialOrderId) {
|
||||
if (preTitle == null || preTitle === '' || stage == null || stage === '') {
|
||||
Dialog.error("前缀或阶段不能为空");
|
||||
} else {
|
||||
Dialog.functionDialog(null, null, 'materialOrder/findPrevStageListDialog.html?adminId=' + adminId + "&preTitle=" + preTitle + "&stage=" + stage + "&materialOrderId=" + materialOrderId);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</div>
|
||||
</html>
|
||||
|
||||
@@ -6,6 +6,9 @@
|
||||
display: inline-block;
|
||||
margin-top: 10px;
|
||||
}
|
||||
.on td{
|
||||
background-color: #BFEFFF; /* 背景颜色*/
|
||||
}
|
||||
</style>
|
||||
<div class="title">
|
||||
<span>以往阶段料单</span>
|
||||
@@ -35,12 +38,13 @@
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<input hidden readonly id="materialOrderId" th:value="${materialOrderId}"/>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="dialogFooter">
|
||||
<div class="dialogFooter center">
|
||||
<a class="cancel">关闭</a>
|
||||
<a th:if="${materialOrderId}" class="confirm">确定</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -49,12 +53,40 @@
|
||||
<script>
|
||||
var flag = true;
|
||||
var $dialog = $(".functionDialog");
|
||||
var $materialOrderId = $("#materialOrderId");
|
||||
Dialog.start({
|
||||
dialog: $dialog,
|
||||
confirm: function () {
|
||||
if($materialOrderId.val()){
|
||||
console.log($materialOrderId.val());
|
||||
var fromData = new FormData();
|
||||
fromData.append("materialOrderId", $materialOrderId.val());
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
cache: false,
|
||||
processData: false,
|
||||
contentType: false,
|
||||
url: 'materialOrder/PrevStageComparisonExcel',
|
||||
dataType: 'json',
|
||||
data: fromData,
|
||||
success: function (res) {
|
||||
if (res.errorCode === '0') {
|
||||
window.open("materialOrder/exportSpecial.html")
|
||||
} else {
|
||||
Dialog.error(res.errorInfo);
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
console.log('ajax error');
|
||||
}
|
||||
});
|
||||
Dialog.close($dialog);
|
||||
} else {
|
||||
Dialog.error("没有找到可比较料单");
|
||||
Dialog.close($dialog);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
</script>
|
||||
</div>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user