344 lines
11 KiB
Java
344 lines
11 KiB
Java
|
|
package com.pms.service;
|
||
|
|
|
||
|
|
import java.util.ArrayList;
|
||
|
|
import java.util.HashMap;
|
||
|
|
import java.util.LinkedHashSet;
|
||
|
|
import java.util.List;
|
||
|
|
import java.util.Map;
|
||
|
|
import java.util.Set;
|
||
|
|
|
||
|
|
import javax.servlet.http.HttpServletRequest;
|
||
|
|
import javax.servlet.http.HttpSession;
|
||
|
|
|
||
|
|
import org.apache.ibatis.session.SqlSession;
|
||
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
||
|
|
import org.springframework.stereotype.Service;
|
||
|
|
|
||
|
|
import com.pms.common.JsonUtil;
|
||
|
|
import com.pms.common.Message;
|
||
|
|
import com.pms.common.SqlMapConfig;
|
||
|
|
import com.pms.common.bean.PersonBean;
|
||
|
|
import com.pms.common.utils.CommonUtils;
|
||
|
|
import com.pms.common.utils.Constants;
|
||
|
|
|
||
|
|
@Service
|
||
|
|
public class SupplyChainMgmtService {
|
||
|
|
|
||
|
|
CommonService commonService = null;
|
||
|
|
|
||
|
|
@Autowired
|
||
|
|
public void setCommonService(CommonService commonService){
|
||
|
|
this.commonService = commonService;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 선택된 값을 접수한다.
|
||
|
|
* @param request
|
||
|
|
* @param paramMap
|
||
|
|
* @return
|
||
|
|
*/
|
||
|
|
public Map regsupplyChain(HttpServletRequest request,Map paramMap){
|
||
|
|
Map resultMap = new HashMap();
|
||
|
|
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
||
|
|
try{
|
||
|
|
|
||
|
|
String checkArr[] = (CommonUtils.checkNull(paramMap.get("checkArr"))).split(",");
|
||
|
|
|
||
|
|
if(0 == checkArr.length){
|
||
|
|
checkArr[0] = CommonUtils.checkNull(paramMap.get("checkArr"));
|
||
|
|
}
|
||
|
|
|
||
|
|
if(null != checkArr && 0 < checkArr.length){
|
||
|
|
Map sqlParamMap = new HashMap();
|
||
|
|
sqlParamMap.put("checkArr",checkArr);
|
||
|
|
sqlSession.update("supplyChainMgmt.regsupplyChain",sqlParamMap);
|
||
|
|
sqlSession.commit();
|
||
|
|
resultMap.put("result", true);
|
||
|
|
resultMap.put("msg", Message.SAVE_SUCCESS);
|
||
|
|
}
|
||
|
|
}catch(Exception e){
|
||
|
|
resultMap.put("result", false);
|
||
|
|
resultMap.put("msg", Message.SAVE_FAILED);
|
||
|
|
sqlSession.rollback();
|
||
|
|
throw e;
|
||
|
|
}finally{
|
||
|
|
sqlSession.close();
|
||
|
|
}
|
||
|
|
return resultMap;
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
public void savearrivalplanFormPopup(HttpServletRequest request, Map<String, Object> paramMap) {
|
||
|
|
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
||
|
|
try {
|
||
|
|
String[] OBJIDs = request.getParameterValues("OBJID");
|
||
|
|
String[] DETAIL_GROUP = request.getParameterValues("DETAIL_GROUP");
|
||
|
|
|
||
|
|
// 삭제 처리
|
||
|
|
String[] deletedObjIds = (String[]) paramMap.get("deletedObjIds");
|
||
|
|
if (deletedObjIds != null) {
|
||
|
|
for (String objId : deletedObjIds) {
|
||
|
|
sqlSession.delete("supplyChainMgmt.deleteArrivalPlan", objId);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
int j = 0;
|
||
|
|
if (OBJIDs != null) {
|
||
|
|
for (int i = 0; i < OBJIDs.length; i++) {
|
||
|
|
String _SEQ = request.getParameterValues("SEQ")[i];
|
||
|
|
int SEQ = Integer.parseInt(_SEQ);
|
||
|
|
Map saveMap = new HashMap();
|
||
|
|
if (0 == SEQ % DETAIL_GROUP.length) {
|
||
|
|
j = DETAIL_GROUP.length;
|
||
|
|
} else {
|
||
|
|
j = SEQ % DETAIL_GROUP.length;
|
||
|
|
}
|
||
|
|
System.out.println("JJJJJJJJJJJJJJJJ ------->" + j);
|
||
|
|
saveMap.put("OBJID", CommonUtils.checkNull(OBJIDs[i], CommonUtils.createObjId()));
|
||
|
|
saveMap.put("PARENT_OBJID", CommonUtils.checkNull(paramMap.get("PARENT_OBJID")));
|
||
|
|
|
||
|
|
saveMap.put("ORDER_PART_OBJID", CommonUtils.checkNull(paramMap.get("ORDER_PART_OBJID_" + j)));
|
||
|
|
saveMap.put("PART_OBJID", CommonUtils.checkNull(paramMap.get("PART_OBJID_" + j)));
|
||
|
|
|
||
|
|
saveMap.put("WRITER", CommonUtils.checkNull(paramMap.get("WRITER")));
|
||
|
|
saveMap.put("GROUP_SEQ", CommonUtils.checkNull(request.getParameterValues("GROUP_SEQ")[i]));
|
||
|
|
saveMap.put("SEQ", CommonUtils.checkNull(request.getParameterValues("SEQ")[i]));
|
||
|
|
saveMap.put("ARRIVAL_QTY", CommonUtils.checkNull(request.getParameterValues("ARRIVAL_QTY")[i]));
|
||
|
|
saveMap.put("ARRIVAL_PLAN_DATE", CommonUtils.checkNull(request.getParameterValues("ARRIVAL_PLAN_DATE")[i]));
|
||
|
|
sqlSession.update("supplyChainMgmt.savearrivalplanFormPopup", saveMap);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
sqlSession.commit();
|
||
|
|
} catch (Exception e) {
|
||
|
|
sqlSession.rollback();
|
||
|
|
throw e;
|
||
|
|
} finally {
|
||
|
|
sqlSession.close();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public void updateSalesStatus(HttpServletRequest request, Map<String, Object> paramMap) {
|
||
|
|
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
||
|
|
try{
|
||
|
|
sqlSession.update("supplyChainMgmt.updateSalesStatus", paramMap);
|
||
|
|
sqlSession.commit();
|
||
|
|
}catch(Exception e){
|
||
|
|
sqlSession.rollback();
|
||
|
|
throw e;
|
||
|
|
}finally{
|
||
|
|
sqlSession.close();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 선택된 값을 접수한다.
|
||
|
|
* @param request
|
||
|
|
* @param paramMap
|
||
|
|
* @return
|
||
|
|
*/
|
||
|
|
public Map saveRedeliverydate(HttpServletRequest request,Map paramMap){
|
||
|
|
Map resultMap = new HashMap();
|
||
|
|
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
||
|
|
try{
|
||
|
|
sqlSession.update("supplyChainMgmt.updateRedeliverydate",paramMap);
|
||
|
|
sqlSession.commit();
|
||
|
|
resultMap.put("result", true);
|
||
|
|
resultMap.put("msg", Message.SAVE_SUCCESS);
|
||
|
|
|
||
|
|
}catch(Exception e){
|
||
|
|
resultMap.put("result", false);
|
||
|
|
resultMap.put("msg", Message.SAVE_FAILED);
|
||
|
|
sqlSession.rollback();
|
||
|
|
throw e;
|
||
|
|
}finally{
|
||
|
|
sqlSession.close();
|
||
|
|
}
|
||
|
|
return resultMap;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 거래명세서를 발행한다.
|
||
|
|
* @param request
|
||
|
|
* @param paramMap
|
||
|
|
* @return
|
||
|
|
*/
|
||
|
|
public Map invoiceIssuance(HttpServletRequest request,Map paramMap){
|
||
|
|
Map resultMap = new HashMap();
|
||
|
|
SqlSession sqlSession = null;
|
||
|
|
|
||
|
|
try{
|
||
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
||
|
|
|
||
|
|
HttpSession session = request.getSession();
|
||
|
|
PersonBean person = (PersonBean)session.getAttribute(Constants.PERSON_BEAN);
|
||
|
|
|
||
|
|
String writer = CommonUtils.checkNull(person.getUserId());
|
||
|
|
|
||
|
|
paramMap.put("WRITER", writer);
|
||
|
|
|
||
|
|
String INVOICE_OBJID = CommonUtils.checkNull(request.getParameter("INVOICE_OBJID"));
|
||
|
|
String status = CommonUtils.checkNull(request.getParameter("STATUS"));
|
||
|
|
|
||
|
|
if("".equals(INVOICE_OBJID)){
|
||
|
|
INVOICE_OBJID = CommonUtils.createObjId();
|
||
|
|
paramMap.put("STATUS", "create");
|
||
|
|
}
|
||
|
|
|
||
|
|
paramMap.put("OBJID", INVOICE_OBJID);
|
||
|
|
|
||
|
|
sqlSession.update("supplyChainMgmt.invoiceIssuance", paramMap);
|
||
|
|
|
||
|
|
sqlSession.update("supplyChainMgmt.initInvoicePart", paramMap);
|
||
|
|
|
||
|
|
String partObjList[] = request.getParameterValues("OBJID");
|
||
|
|
|
||
|
|
if(null != partObjList && 0 < partObjList.length){
|
||
|
|
for(String targetObjId:partObjList){
|
||
|
|
|
||
|
|
Map sqlParamMep = new HashMap();
|
||
|
|
|
||
|
|
sqlParamMep.put("OBJID", CommonUtils.createObjId());
|
||
|
|
sqlParamMep.put("PART_OBJID", CommonUtils.checkNull(request.getParameter("PART_OBJID_"+targetObjId)));
|
||
|
|
//sqlParamMep.put("PART_NAME", CommonUtils.checkNull(request.getParameter("PART_NAME_"+targetObjId)));
|
||
|
|
sqlParamMep.put("INVOICE_OBJID", INVOICE_OBJID);
|
||
|
|
sqlParamMep.put("QTY", CommonUtils.checkNull(request.getParameter("QTY_"+targetObjId)));
|
||
|
|
sqlParamMep.put("UNIT_PRICE", CommonUtils.checkNull(request.getParameter("UNIT_PRICE_"+targetObjId)));
|
||
|
|
sqlParamMep.put("PARTNER_PRICE", CommonUtils.checkNull(request.getParameter("PARTNER_PRICE_"+targetObjId)));
|
||
|
|
sqlParamMep.put("VAT_PRICE", CommonUtils.checkNull(request.getParameter("VAT_PRICE_"+targetObjId)));
|
||
|
|
sqlParamMep.put("WRITER", writer);
|
||
|
|
sqlParamMep.put("STATUS", CommonUtils.checkNull(request.getParameter("STATUS_"+targetObjId),"create"));
|
||
|
|
sqlParamMep.put("REMARK", CommonUtils.checkNull(request.getParameter("REMARK_"+targetObjId)));
|
||
|
|
sqlParamMep.put("RECEIPT_DATE", CommonUtils.checkNull(request.getParameter("RECEIPT_DATE_"+targetObjId)));
|
||
|
|
|
||
|
|
sqlSession.update("supplyChainMgmt.mergeInvoicePartInfo", sqlParamMep);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
sqlSession.commit();
|
||
|
|
|
||
|
|
resultMap.put("result", true);
|
||
|
|
resultMap.put("msg", Message.SAVE_SUCCESS);
|
||
|
|
|
||
|
|
}catch(Exception e){
|
||
|
|
sqlSession.rollback();
|
||
|
|
|
||
|
|
resultMap.put("result", false);
|
||
|
|
resultMap.put("msg", Message.SAVE_FAILED);
|
||
|
|
|
||
|
|
e.printStackTrace();
|
||
|
|
}finally{
|
||
|
|
sqlSession.close();
|
||
|
|
}
|
||
|
|
|
||
|
|
return resultMap;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 거래명세서 월별 마감
|
||
|
|
* @param request
|
||
|
|
* @param paramMap
|
||
|
|
* @return
|
||
|
|
*/
|
||
|
|
public Map invoiceConfirm(HttpServletRequest request,Map paramMap){
|
||
|
|
Map resultMap = new HashMap();
|
||
|
|
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
||
|
|
try{
|
||
|
|
|
||
|
|
String checkParam = CommonUtils.checkNull(paramMap.get("checkArr"));
|
||
|
|
String[] targetObjIdList = checkParam.split(",");
|
||
|
|
|
||
|
|
if(null != targetObjIdList && 0 < targetObjIdList.length){
|
||
|
|
|
||
|
|
HttpSession session = request.getSession();
|
||
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||
|
|
PersonBean person = (PersonBean)session.getAttribute(Constants.PERSON_BEAN);
|
||
|
|
|
||
|
|
String userId = person.getUserId();
|
||
|
|
|
||
|
|
for(int i=0;i<targetObjIdList.length;i++){
|
||
|
|
String objId = CommonUtils.checkNull(targetObjIdList[i]);
|
||
|
|
HashMap sqlParamMap = new HashMap();
|
||
|
|
sqlParamMap.put("OBJID", objId);
|
||
|
|
sqlSession.update("supplyChainMgmt.invoiceConfirm",sqlParamMap);
|
||
|
|
}
|
||
|
|
sqlSession.commit();
|
||
|
|
resultMap.put("result", true);
|
||
|
|
resultMap.put("msg", "확인되었습니다");
|
||
|
|
}
|
||
|
|
}catch(Exception e){
|
||
|
|
resultMap.put("result", false);
|
||
|
|
resultMap.put("msg", "확인에 실패하였습니다");
|
||
|
|
sqlSession.rollback();
|
||
|
|
throw e;
|
||
|
|
}finally{
|
||
|
|
sqlSession.close();
|
||
|
|
}
|
||
|
|
return resultMap;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 자금지급관리 예정일 저장
|
||
|
|
* @param paramMap
|
||
|
|
* @return
|
||
|
|
*/
|
||
|
|
public boolean saveDueDateInfo(Map paramMap){
|
||
|
|
boolean result = false;
|
||
|
|
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||
|
|
|
||
|
|
try{
|
||
|
|
int cnt = sqlSession.update("supplyChainMgmt.saveDueDateInfo", paramMap);
|
||
|
|
if(cnt > 0) result = true;
|
||
|
|
}catch(Exception e){
|
||
|
|
e.printStackTrace();
|
||
|
|
}finally{
|
||
|
|
sqlSession.close();
|
||
|
|
}
|
||
|
|
|
||
|
|
return result;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 거래명세서 지급완료
|
||
|
|
* @param request
|
||
|
|
* @param paramMap
|
||
|
|
* @return
|
||
|
|
*/
|
||
|
|
public Map invoiceComplete(HttpServletRequest request,Map paramMap){
|
||
|
|
Map resultMap = new HashMap();
|
||
|
|
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
||
|
|
try{
|
||
|
|
|
||
|
|
String checkParam = CommonUtils.checkNull(paramMap.get("checkArr"));
|
||
|
|
String[] targetObjIdList = checkParam.split(",");
|
||
|
|
|
||
|
|
if(null != targetObjIdList && 0 < targetObjIdList.length){
|
||
|
|
|
||
|
|
HttpSession session = request.getSession();
|
||
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||
|
|
PersonBean person = (PersonBean)session.getAttribute(Constants.PERSON_BEAN);
|
||
|
|
|
||
|
|
String userId = person.getUserId();
|
||
|
|
|
||
|
|
for(int i=0;i<targetObjIdList.length;i++){
|
||
|
|
String objId = CommonUtils.checkNull(targetObjIdList[i]);
|
||
|
|
HashMap sqlParamMap = new HashMap();
|
||
|
|
sqlParamMap.put("OBJID", objId);
|
||
|
|
sqlSession.update("supplyChainMgmt.invoiceComplete",sqlParamMap);
|
||
|
|
}
|
||
|
|
sqlSession.commit();
|
||
|
|
resultMap.put("result", true);
|
||
|
|
resultMap.put("msg", "확인되었습니다");
|
||
|
|
}
|
||
|
|
}catch(Exception e){
|
||
|
|
resultMap.put("result", false);
|
||
|
|
resultMap.put("msg", "확인에 실패하였습니다");
|
||
|
|
sqlSession.rollback();
|
||
|
|
throw e;
|
||
|
|
}finally{
|
||
|
|
sqlSession.close();
|
||
|
|
}
|
||
|
|
return resultMap;
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|